package com.yong.mestock.mapper;

import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;
@Mapper
public interface StockCodeListMapper {

    //根据时间，获取未保存的codeinfo
    @Select({"<script>" +
            "select * from stockcodelist where 1=1 " +
            "<when test='time!=null'>" +
            "and stockcode not in (select code  from stockinfoeveryday where infodate = #{time})" +
            "</when>" +
            "</script>"})
    List<Map<String, String>> findNotSaveCode(@Param("time") String time);

    @Select("select * from stockList where code = #{code}")
    Map<String,String > findStockListByCode(@Param("code") String code);

//    stockcodeList保存
    @Insert({"<script>" ,
            "insert into STOCKCODELIST(TS_CODE,STOCKCODE,STOCKNAME,LOCATION,INDUSTRY,FULLNAMEOFSTOCK,MARKETCATEGORY,LISTSTATUS,LISTDATE)  ",
            "<foreach collection='list' item='item'  index='index' separator=' union '>",
            "(select '${item[0]}','${item[1]}','${item[2]}','${item[3]}','${item[4]}','${item[5]}','${item[6]}','${item[7]}','${item[8]}' from dual) ",
            "</foreach>",
            "</script>"})
    int saveStockCodeList(@Param("list") List<List> list);

    @Delete("delete from STOCKCODELIST")
    int deleteStockList();





}
